package code.example.base.data.struct.sort;

public class InsertionSort implements Sorter {
    @Override
    public void sort(int[] data) {
        for (int i = 1; i < data.length; i++) {
            int current = data[i];
            int j = i;
            for (; j > 0; j--) {
                if (current < data[j - 1]) {
                    data[j] = data[j - 1];
                } else {
                    break;
                }
            }
            data[j] = current;
        }
    }
}
